const formatTime = date => {
  var date = new Date()
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
function formatTimeWithTimeStamp(unixtime, format) {
  var time = getDate(unixtime);
  var year = time.getFullYear();
  var month = time.getMonth() + 1;
  var date = time.getDate();
  var hour = time.getHours();
  var minute = time.getMinutes();
  var second = time.getSeconds();
  month = month < 10 ? "0" + month : month;
  date = date < 10 ? "0" + date : date;
  hour = hour < 10 ? "0" + hour : hour;
  minute = minute < 10 ? "0" + minute : minute;
  second = second < 10 ? "0" + second : second;
  return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}


const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
function testAuth(authorName,callback){
  wx.getSetting({
    complete: (res) => {
      callback(res.authSetting[authorName])
    },
  })
  wx.navigateTo({
    url: 'url?',
  })
}
module.exports = {
  formatTime: formatTime,
  formatTimeWithTimeStamp:formatTimeWithTimeStamp,
  testAuth:testAuth
}
